package com.foodconflict.util;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;

public class StringConvertor {
	
	private String dataString;
	
	public StringConvertor(String dataString)
	{
		this.dataString = dataString;
	}
	
	public Date toDate(String formatString)
	{
		Date result = null;
		try {
			result = (new SimpleDateFormat(formatString)).parse(this.dataString);
		} catch (ParseException e) {
			e.printStackTrace();
		}
		return result;
	}
	
	public int toInt(int defaultValue)
	{
		int result = defaultValue;
		try
		{
			result = Integer.parseInt(this.dataString);
		}
		catch (Exception e) {
			e.printStackTrace();
		}
		return result;
	}
}
